<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mjb="http://www.michaelbraude.com/document/version1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<xsl:output method="xml" encoding="UTF-8" indent="yes" media-type="application/xaml+xml" omit-xml-declaration="yes"/>
	<xsl:param name="QueryString"/>
	<!-- This will match the main content element -->
	<xsl:template match="mjb:Content">
		<Page xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
			<xsl:attribute name="Title"><xsl:value-of select="ContentProperties/Title"/></xsl:attribute>
			<Page.Resources>
				<!-- Colors -->
				<Brush x:Key="contentBackgroundBrush">#6E6E6E</Brush>
				<Brush x:Key="leftBackgroundBrush">#003562</Brush>
				<Brush x:Key="rightBackgroundBrush">#01437B</Brush>
				<Brush x:Key="borderBrush">White</Brush>
				<Brush x:Key="contentTitleBarBrush">#AEAEAE</Brush>
				<!-- Templates -->
				<StackPanel Orientation="Horizontal" x:Key="leftBackgroundTemplate">
					<Rectangle Width="104" Height="1">
						<Rectangle.Fill>
							<LinearGradientBrush>
								<GradientStop Offset="0" Color="#BEBEBE"/>
								<GradientStop Offset="1" Color="#6E6E6E"/>
							</LinearGradientBrush>
						</Rectangle.Fill>
					</Rectangle>
					<xsl:element name="Rectangle">
						<xsl:attribute name="Width">2</xsl:attribute>
						<xsl:attribute name="Height">1</xsl:attribute>
						<xsl:attribute name="Fill">{StaticResource borderBrush}</xsl:attribute>
					</xsl:element>
					<Rectangle Width="8" Height="1">
						<Rectangle.Fill>
							<LinearGradientBrush>
								<GradientStop Offset="0" Color="Black"/>
								<GradientStop Offset="1" Color="#01437B"/>
							</LinearGradientBrush>
						</Rectangle.Fill>
					</Rectangle>
					<xsl:element name="Rectangle">
						<xsl:attribute name="Width">80</xsl:attribute>
						<xsl:attribute name="Height">1</xsl:attribute>
						<xsl:attribute name="Fill">{StaticResource rightBackgroundBrush}</xsl:attribute>
					</xsl:element>
				</StackPanel>
				<!-- Control Templates -->
				<!-- This is the control template that replaces the toggle button -->
				<xsl:element name="ControlTemplate">
					<xsl:attribute name="x:Key">toggleButtonTemplate</xsl:attribute>
					<xsl:attribute name="TargetType">{x:Type ToggleButton}</xsl:attribute>
					<Grid Cursor="Hand">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*"/>
							<ColumnDefinition Width="12"/>
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition/>
						</Grid.RowDefinitions>
						<xsl:element name="ContentPresenter">
							<xsl:attribute name="Grid.Column">0</xsl:attribute>
							<xsl:attribute name="Grid.Row">0</xsl:attribute>
							<xsl:attribute name="Content">{TemplateBinding Content}</xsl:attribute>
							<xsl:attribute name="VerticalAlignment">Center</xsl:attribute>
							<xsl:attribute name="Margin">2,0,0,0</xsl:attribute>
						</xsl:element>
						<Grid Grid.Row="0" Grid.Column="1" Width="12" Height="12" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="Hand">
							<xsl:element name="Ellipse">
								<xsl:attribute name="Width">12</xsl:attribute>
								<xsl:attribute name="Height">12</xsl:attribute>
								<xsl:attribute name="Stroke">{TemplateBinding Foreground}</xsl:attribute>
								<xsl:attribute name="StrokeThickness">1</xsl:attribute>
								<xsl:attribute name="Fill">Transparent</xsl:attribute>
							</xsl:element>
							<xsl:element name="Path">
								<xsl:attribute name="x:Name">arrowPath</xsl:attribute>
								<xsl:attribute name="Stroke">{TemplateBinding Foreground}</xsl:attribute>
								<xsl:attribute name="StrokeThickness">1</xsl:attribute>
								<xsl:attribute name="Fill">Transparent</xsl:attribute>
							</xsl:element>
						</Grid>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="Foreground" Value="White"/>
						</Trigger>
						<Trigger Property="IsChecked" Value="True">
							<Setter TargetName="arrowPath" Property="Data" Value="M 3, 4 L 6, 8 L 9, 4"/>
						</Trigger>
						<Trigger Property="IsChecked" Value="False">
							<Setter TargetName="arrowPath" Property="Data" Value="M 3, 8 L 6, 4 L 9, 8"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</xsl:element>
				<!-- This control template replaces the expander! -->
				<!-- This control template replaces the expander -->
				<xsl:element name="ControlTemplate">
					<xsl:attribute name="x:Key">expanderTemplate</xsl:attribute>
					<xsl:attribute name="TargetType">{x:Type Expander}</xsl:attribute>
					<xsl:element name="Border">
						<xsl:attribute name="BorderBrush">{TemplateBinding BorderBrush}</xsl:attribute>
						<xsl:attribute name="BorderThickness">{TemplateBinding BorderThickness}</xsl:attribute>
						<xsl:element name="StackPanel">
							<xsl:attribute name="Background">{TemplateBinding Background}</xsl:attribute>
							<Grid>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="*"/>
								</Grid.ColumnDefinitions>
								<Grid.RowDefinitions>
									<RowDefinition/>
									<RowDefinition/>
								</Grid.RowDefinitions>
								<!-- The toggle button replaces the header part of the expander -->
								<xsl:element name="ToggleButton">
									<xsl:attribute name="Grid.Column">0</xsl:attribute>
									<xsl:attribute name="Grid.Row">0</xsl:attribute>
									<xsl:attribute name="VerticalAlignment">Center</xsl:attribute>
									<xsl:attribute name="Margin">2</xsl:attribute>
									<xsl:attribute name="IsChecked">{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}</xsl:attribute>
									<xsl:attribute name="Content">{TemplateBinding Header}</xsl:attribute>
								</xsl:element>
								<xsl:element name="ContentPresenter">
									<xsl:attribute name="x:Name">expanderContent</xsl:attribute>
									<xsl:attribute name="Grid.Column">0</xsl:attribute>
									<xsl:attribute name="Grid.Row">1</xsl:attribute>
									<xsl:attribute name="Content">{TemplateBinding Content}</xsl:attribute>
									<ContentPresenter.LayoutTransform>
										<TransformGroup>
											<ScaleTransform ScaleX="1" ScaleY="1"/>
										</TransformGroup>
									</ContentPresenter.LayoutTransform>
								</xsl:element>
							</Grid>
						</xsl:element>
					</xsl:element>
					<ControlTemplate.Triggers>
						<EventTrigger RoutedEvent="Expander.Expanded">
							<EventTrigger.Actions>
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="expanderContent" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.001"/>
											<SplineDoubleKeyFrame KeyTime="00:00:00.3" Value="1"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</BeginStoryboard>
							</EventTrigger.Actions>
						</EventTrigger>
						<EventTrigger RoutedEvent="Expander.Collapsed">
							<EventTrigger.Actions>
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="expanderContent" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
											<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
											<SplineDoubleKeyFrame KeyTime="00:00:00.3" Value="0.001"/>
										</DoubleAnimationUsingKeyFrames>
									</Storyboard>
								</BeginStoryboard>
							</EventTrigger.Actions>
						</EventTrigger>
					</ControlTemplate.Triggers>
				</xsl:element>
				<!-- Styles -->
				<xsl:element name="Style">
					<xsl:attribute name="x:Key">hyperLinkStyle</xsl:attribute>
					<xsl:attribute name="TargetType">{x:Type Hyperlink}</xsl:attribute>
					<xsl:element name="Setter">
						<xsl:attribute name="Property">Foreground</xsl:attribute>
						<xsl:attribute name="Value">{StaticResource borderBrush}</xsl:attribute>
					</xsl:element>
					<Style.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Trigger.EnterActions>
								<BeginStoryboard>
									<Storyboard TargetProperty="Foreground.Color">
										<ColorAnimation From="White" To="Red" Duration="0:0:.2"/>
									</Storyboard>
								</BeginStoryboard>
							</Trigger.EnterActions>
							<Trigger.ExitActions>
								<BeginStoryboard>
									<Storyboard TargetProperty="Foreground.Color">
										<ColorAnimation From="Red" To="White" Duration="0:0:.2"/>
									</Storyboard>
								</BeginStoryboard>
							</Trigger.ExitActions>
							<Setter Property="Cursor" Value="Hand"/>
						</Trigger>
					</Style.Triggers>
				</xsl:element>
				<xsl:element name="Style">
					<xsl:attribute name="TargetType">{x:Type Expander}</xsl:attribute>
					<xsl:element name="Setter">
						<xsl:attribute name="Property">Template</xsl:attribute>
						<xsl:attribute name="Value">{StaticResource expanderTemplate}</xsl:attribute>
					</xsl:element>
				</xsl:element>
				<xsl:element name="Style">
					<xsl:attribute name="TargetType">{x:Type ToggleButton}</xsl:attribute>
					<xsl:element name="Setter">
						<xsl:attribute name="Property">Template</xsl:attribute>
						<xsl:attribute name="Value">{StaticResource toggleButtonTemplate}</xsl:attribute>
					</xsl:element>
				</xsl:element>
			</Page.Resources>
			<xsl:element name="Grid">
				<xsl:attribute name="Background">{StaticResource rightBackgroundBrush}</xsl:attribute>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="200"/>
					<ColumnDefinition Width="*"/>
				</Grid.ColumnDefinitions>
				<Grid.RowDefinitions>
					<RowDefinition Height="*"/>
				</Grid.RowDefinitions>
				<!-- This is the left column -->
				<StackPanel Width="200" Grid.Column="0" Grid.Row="0">
					<StackPanel.Background>
						<xsl:element name="VisualBrush">
							<xsl:attribute name="TileMode">Tile</xsl:attribute>
							<xsl:attribute name="Viewport">0,0,1,1</xsl:attribute>
							<xsl:attribute name="Visual">{StaticResource leftBackgroundTemplate}</xsl:attribute>
						</xsl:element>
					</StackPanel.Background>
					<Image Source="http://michaelbraude.com/Images/Face.gif" Width="160" Height="160" Margin="40,40,0,0" ToolTip="Michael Braude"/>
					<xsl:element name="Expander">
						<xsl:attribute name="IsExpanded">True</xsl:attribute>
						<xsl:attribute name="Background">{StaticResource contentTitleBarBrush}</xsl:attribute>
						<xsl:attribute name="BorderBrush">{StaticResource borderBrush}</xsl:attribute>
						<xsl:attribute name="BorderThickness">2</xsl:attribute>
						<xsl:attribute name="Margin">40,10,0,0</xsl:attribute>
						<xsl:attribute name="Header">Navigation</xsl:attribute>
						<xsl:element name="Border">
							<xsl:attribute name="BorderBrush">{StaticResource borderBrush}</xsl:attribute>
							<xsl:attribute name="BorderThickness">0,2,0,0</xsl:attribute>
							<xsl:element name="StackPanel">
								<xsl:attribute name="Background">{StaticResource contentBackgroundBrush}</xsl:attribute>
								<xsl:element name="TextBlock">
									<xsl:attribute name="Foreground">{StaticResource borderBrush}</xsl:attribute>
									<xsl:attribute name="Margin">4,0,0,4</xsl:attribute>
									<xsl:element name="Hyperlink">
										<xsl:attribute name="NavigateUri">indexXAML.php?XML/Biography.xml</xsl:attribute>
										<xsl:attribute name="Style">{StaticResource hyperLinkStyle}</xsl:attribute>
										<xsl:value-of select="'BIO'"/>
									</xsl:element>
									<LineBreak/>
									<xsl:element name="Hyperlink">
										<xsl:attribute name="NavigateUri">indexXAML.php?XML/Resume.xml</xsl:attribute>
										<xsl:attribute name="Style">{StaticResource hyperLinkStyle}</xsl:attribute>
										<xsl:value-of select="'Resume'"/>
									</xsl:element>
									<LineBreak/>
									<xsl:element name="Hyperlink">
										<xsl:attribute name="NavigateUri">indexXAML.php?XML/Projects/Index.xml</xsl:attribute>
										<xsl:attribute name="Style">{StaticResource hyperLinkStyle}</xsl:attribute>
										<xsl:value-of select="'Projects'"/>
									</xsl:element>
                                    <LineBreak/>
                                    <xsl:element name="Hyperlink">
                                        <xsl:attribute name="NavigateUri">indexXAML.php?XML/Articles/Index.xml</xsl:attribute>
                                        <xsl:attribute name="Style">{StaticResource hyperLinkStyle}</xsl:attribute>
                                        <xsl:value-of select="'Articles'"/>
                                    </xsl:element>
									<LineBreak/>
									<xsl:element name="Hyperlink">
										<xsl:attribute name="NavigateUri">indexXAML.php?XML/Blog/Index.xml</xsl:attribute>
										<xsl:attribute name="Style">{StaticResource hyperLinkStyle}</xsl:attribute>
										<xsl:value-of select="'Blog'"/>
									</xsl:element>
									<LineBreak/>
									<xsl:element name="Hyperlink">
										<xsl:attribute name="NavigateUri">indexXAML.php?XML/TechnicalBlog/Index.xml</xsl:attribute>
										<xsl:attribute name="Style">{StaticResource hyperLinkStyle}</xsl:attribute>
										<xsl:value-of select="'Tech Blog'"/>
									</xsl:element>
								</xsl:element>
							</xsl:element>
						</xsl:element>
					</xsl:element>
					<TextBlock Margin="64,15,0,0">
						<xsl:element name="Hyperlink">
							<xsl:attribute name="NavigateUri"><xsl:value-of select="concat('http://www.michaelbraude.com/rss.php?', $QueryString)"/></xsl:attribute>
							<xsl:attribute name="Foreground">Transparent</xsl:attribute>
							<xsl:element name="Image">
								<xsl:attribute name="Source">http://michaelbraude.com/Images/RSS.gif</xsl:attribute>
								<xsl:attribute name="Width">36</xsl:attribute>
								<xsl:attribute name="Height">17</xsl:attribute>
							</xsl:element>
						</xsl:element>
					</TextBlock>
				</StackPanel>
				<!-- This is the right column -->
				<ScrollViewer Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Visible">
					<Grid HorizontalAlignment="Left">
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="592"/>
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="200"/>
							<RowDefinition Height="*"/>
						</Grid.RowDefinitions>
						<TextBlock VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" Margin="15,0,0,0" Width="577" Height="200">
							<Hyperlink NavigateUri="http://www.michaelbraude.com" Foreground="Transparent">
								<Image Source="http://michaelbraude.com/Images/Banner.gif" Width="577" Height="61" Margin="0,87,0,0" ToolTip="www.michaelbraude.com"/>
							</Hyperlink>
						</TextBlock>
						<StackPanel Margin="15,0,0,50" Grid.Row="1">
							<!-- This is where we will auto-generate our content! -->
							<xsl:apply-templates select="Sections"/>
						</StackPanel>
					</Grid>
				</ScrollViewer>
			</xsl:element>
		</Page>
	</xsl:template>
	<!-- This is the template for translating individual section values -->
	<xsl:template match="Section">
		<xsl:element name="Expander">
			<xsl:attribute name="IsExpanded">True</xsl:attribute>
			<xsl:attribute name="Background">{StaticResource contentTitleBarBrush}</xsl:attribute>
			<xsl:attribute name="BorderBrush">{StaticResource borderBrush}</xsl:attribute>
			<xsl:attribute name="BorderThickness">2</xsl:attribute>
			<xsl:attribute name="Margin">0,10,0,0</xsl:attribute>
			<xsl:attribute name="Header"><xsl:value-of select="@Title"/><xsl:if test="@LastModified != ''"><xsl:value-of select="' - '"/><xsl:value-of select="@LastModified"/></xsl:if></xsl:attribute>
			<xsl:element name="Border">
				<xsl:attribute name="BorderBrush">{StaticResource borderBrush}</xsl:attribute>
				<xsl:attribute name="BorderThickness">0,2,0,0</xsl:attribute>
				<xsl:element name="TextBlock">
					<xsl:attribute name="Foreground">{StaticResource borderBrush}</xsl:attribute>
					<xsl:attribute name="Background">{StaticResource contentBackgroundBrush}</xsl:attribute>
					<xsl:attribute name="TextWrapping">Wrap</xsl:attribute>
					<xsl:attribute name="Padding">2</xsl:attribute>
					<xsl:apply-templates/>
				</xsl:element>
			</xsl:element>
		</xsl:element>
	</xsl:template>
	<!-- Text Formatting templates -->
	<xsl:template match="Bold">
		<Bold>
			<xsl:apply-templates/>
		</Bold>
	</xsl:template>
	<xsl:template match="Newline">
		<LineBreak/>
	</xsl:template>
	<xsl:template match="NewParagraph">
		<LineBreak/>
		<LineBreak/>
	</xsl:template>
	<xsl:template match="List">
		<LineBreak/>
        <LineBreak/>
		<xsl:for-each select="ListElement">
			<BulletDecorator Margin="4,0,0,0">
				<BulletDecorator.Bullet>
					<xsl:element name="Ellipse">
						<xsl:attribute name="Width">4</xsl:attribute>
						<xsl:attribute name="Height">4</xsl:attribute>
						<xsl:attribute name="Fill">{StaticResource borderBrush}</xsl:attribute>
					</xsl:element>
				</BulletDecorator.Bullet>
				<TextBlock Margin="4,0,0,0" TextWrapping="Wrap">
                    <xsl:apply-templates select="." />
				</TextBlock>
			</BulletDecorator>
			<LineBreak/>
		</xsl:for-each>
        <LineBreak/>
	</xsl:template>
	<xsl:template match="ContentLink">
		<xsl:element name="Hyperlink">
			<xsl:attribute name="NavigateUri">indexXAML.php?XML/<xsl:value-of select="@href"/></xsl:attribute>
			<xsl:attribute name="Style">{StaticResource hyperLinkStyle}</xsl:attribute>
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>
	<xsl:template match="ExternalLink">
		<xsl:element name="Hyperlink">
			<xsl:attribute name="NavigateUri"><xsl:value-of select="@href"/></xsl:attribute>
			<xsl:attribute name="Style">{StaticResource hyperLinkStyle}</xsl:attribute>
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>
	<!-- These values will generate 'table' structures -->
	<xsl:template match="Table">
		<LineBreak/>
		<InlineUIContainer>
			<StackPanel Width="577">
				<xsl:apply-templates select="TableRow"/>
			</StackPanel>
		</InlineUIContainer>
		<LineBreak/>
	</xsl:template>
	<xsl:template match="TableRow">
		<Grid>
			<Grid.ColumnDefinitions>
				<xsl:for-each select="TableCell">
					<xsl:element name="ColumnDefinition">
						<xsl:attribute name="Width"><xsl:value-of select="'.'"/><xsl:value-of select="@WidthPercent"/><xsl:value-of select="'*'"/></xsl:attribute>
					</xsl:element>
				</xsl:for-each>
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition/>
			</Grid.RowDefinitions>
			<xsl:for-each select="TableCell">
				<xsl:element name="TextBlock">
					<xsl:attribute name="Grid.Row">0</xsl:attribute>
					<xsl:attribute name="Grid.Column"><xsl:value-of select="position() - 1"/></xsl:attribute>
					<xsl:apply-templates select="node()"/>
				</xsl:element>
			</xsl:for-each>
		</Grid>
	</xsl:template>
	<xsl:template match="TableCell">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="Image">
		<LineBreak/>
		<LineBreak/>
		<InlineUIContainer>
			<StackPanel Width="577" HorizontalAlignment="Center">
				<xsl:element name="Image">
					<xsl:attribute name="Source"><xsl:value-of select="@href"/></xsl:attribute>
					<xsl:attribute name="Width"><xsl:value-of select="@width"/></xsl:attribute>
					<xsl:attribute name="Height"><xsl:value-of select="@height"/></xsl:attribute>
				</xsl:element>
			</StackPanel>
		</InlineUIContainer>
		<LineBreak/>
		<LineBreak/>
	</xsl:template>
	<xsl:template match="Code">
		<TextBlock Width="573" Background="Beige" Foreground="Black" Margin="2" Padding="2" HorizontalAlignment="Stretch" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled">
			<Run xml:space="preserve">
				<xsl:apply-templates/>
			</Run>
		</TextBlock>
	</xsl:template>
</xsl:stylesheet>
